package top.roud.dao.query;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import top.roud.bean.User;
import top.roud.dao.utils.JdbcUtils;
import top.roud.dao.utils.GetPropertiesUtils;
public class UserExits {
	public static boolean userIsExists(User u) throws Exception {
		Connection conn = null;
		ResultSet rs =null;
		PreparedStatement ps = null;
		String sql = null;
		try {
			sql = GetPropertiesUtils.getResult("sql.properties","veriftiesuser");
			conn = JdbcUtils.getConnection();
			 
			 ps = conn.prepareStatement(sql);
			 ps.setString(1, u.getPhone());
			 ps.setString(2, u.getPwd());
			 rs = ps.executeQuery();
			 if(rs.next()) {
				 return true;
			 }else{
				 return false;
			 }
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			if(conn!=null) {
				conn.close();
			}
			if(ps!=null) {
				ps.close();
			}
			if(rs!=null) {
				rs.close();
			}
			
		}
		return false;
	}
}
